﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using CLibArtreve.bll;

namespace WebAppArtreve.views.shared.components.categories
{
    public partial class WUCCategoryImage : System.Web.UI.UserControl
    {
        //VARIABLES
        private Int64 _categoryId;
        private string _connectionString
        {
            get
            {
                return ConfigurationManager.ConnectionStrings["ARTREVEConnectionString"].ConnectionString;
            }
        }

        //PROPERTIES
        public Int64 CategoryId
        {
            get
            {
                return _categoryId;
            }
            set
            {
                _categoryId = value;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        //GET THE URL FOR THE IMAGE (WEBCONFIG->DMSPATH + FILENAME)
        protected string GetRealImageURL(string argument)
        {
            return ConfigurationManager.AppSettings["DMSPATHCAT"] + argument;
        }

        //VOORDAT SELECT IN ODS WORDT UITGEVOERD
        protected void ODSArtsALL_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
        {
            int count = Request.QueryString.Count;
            if (count > 0)
            {
                e.InputParameters["Id"] = Request.QueryString["Id"];
            }
            else
            {
                e.InputParameters["Id"] = CategoryId;
            }

        }

        protected void ODSCategoryImageById_OnObjectCreating(object sender, ObjectDataSourceEventArgs e)
        {
            //STEP 2. CREATE BLL
            CategoryBLL ObjectInstance = new CategoryBLL(_connectionString);
            //STEP 3. CONNECT TYPENAME
            e.ObjectInstance = ObjectInstance;
        }
    }
}